define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格參數配置
            Table.api.init({
                extend: {
                    index_url: 'jdy/bulletin/index',
                    add_url: 'jdy/bulletin/add',
                    edit_url: 'jdy/bulletin/edit',
                    del_url: 'jdy/bulletin/del',
                    multi_url: 'jdy/bulletin/multi',
                    table: 'jdy_bulletin',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showColumns: true,
                showExport: false,
                searchFormVisible: true,
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
                        //{field: 'anchang_id', title: __('Anchang_id')},
                        //{field: 'task_id', title: __('Task_id')},
                        {field: 'anchang.name', title: __('Anchang.name'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'task.title', title: __('Task.title'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'question', title: __('Question'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'question_user', title: __('Question_user'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'answer', title: __('Answer'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'answer_user', title: __('Answer_user'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'anchang.id', title: __('Anchang.id')},
                        //{field: 'anchang.building_id', title: __('Anchang.building_id')},
                        //{field: 'anchang.room_id', title: __('Anchang.room_id')},
                        //{field: 'anchang.name', title: __('Anchang.name')},
                        //{field: 'anchang.addr', title: __('Anchang.addr')},
                        //{field: 'anchang.remark', title: __('Anchang.remark')},
                        //{field: 'anchang.contact1_id', title: __('Anchang.contact1_id')},
                        //{field: 'anchang.contact2_id', title: __('Anchang.contact2_id')},
                        //{field: 'anchang.companywindow_id', title: __('Anchang.companywindow_id')},
                        //{field: 'anchang.xianshi', title: __('Anchang.xianshi')},
                        //{field: 'anchang.xzq', title: __('Anchang.xzq')},
                        //{field: 'anchang.mapurl', title: __('Anchang.mapurl'), formatter: Table.api.formatter.url},
                        //{field: 'anchang.orderdate', title: __('Anchang.orderdate'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'anchang.create_time', title: __('Anchang.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'anchang.update_time', title: __('Anchang.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'task.id', title: __('Task.id')},
                        //{field: 'task.anchang_id', title: __('Task.anchang_id')},
                        //{field: 'task.acdevice_id', title: __('Task.acdevice_id')},
                        //{field: 'task.stype_id', title: __('Task.stype_id')},
                        //{field: 'task.task_type', title: __('Task.task_type')},
                        //{field: 'task.remind_start_date', title: __('Task.remind_start_date'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'task.remind_end_date', title: __('Task.remind_end_date'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'task.again_launch', title: __('Task.again_launch')},
                        //{field: 'task.again_day', title: __('Task.again_day')},
                        //{field: 'task.line_again_launch', title: __('Task.line_again_launch')},
                        //{field: 'task.line_again_day', title: __('Task.line_again_day')},
                        //{field: 'task.quotation_no', title: __('Task.quotation_no')},
                        //{field: 'task.work_no', title: __('Task.work_no')},
                        //{field: 'task.title', title: __('Task.title')},
                        //{field: 'task.task_status', title: __('Task.task_status')},
                        //{field: 'task.maintenance_user_sn', title: __('Task.maintenance_user_sn')},
                        //{field: 'task.handle_user_sn', title: __('Task.handle_user_sn')},
                        //{field: 'task.photo1', title: __('Task.photo1')},
                        //{field: 'task.photo2', title: __('Task.photo2')},
                        //{field: 'task.photo3', title: __('Task.photo3')},
                        //{field: 'task.photo4', title: __('Task.photo4')},
                        //{field: 'task.photo5', title: __('Task.photo5')},
                        //{field: 'task.price', title: __('Task.price')},
                        //{field: 'task.repair_log_sn', title: __('Task.repair_log_sn')},
                        //{field: 'task.notify_user_sn_list', title: __('Task.notify_user_sn_list')},
                        //{field: 'task.line_msg_sdate', title: __('Task.line_msg_sdate'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'task.line_msg_edate', title: __('Task.line_msg_edate'), operate:'RANGE', addclass:'datetimerange'},
                        //{field: 'task.show', title: __('Task.show')},
                        //{field: 'task.share_to_comm', title: __('Task.share_to_comm')},
                        //{field: 'task.notify_msg', title: __('Task.notify_msg')},
                        //{field: 'task.del', title: __('Task.del')},
                        //{field: 'task.luruman', title: __('Task.luruman')},
                        //{field: 'task.opman', title: __('Task.opman')},
                        //{field: 'task.create_time', title: __('Task.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'task.update_time', title: __('Task.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                    ]
                ]
            });

            // 為表格綁定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});